package com.zlk.algorithm.huawei.leetcode.binaryTree;


import com.zlk.algorithm.util.TreeNode;
import org.junit.Test;

import java.util.Stack;

/**
 * @program: algorithm
 * @ClassName Code25_isSymmetric
 * @description:对称二叉树
 * @author: slfang
 * @create: 2025-01-08 10:59
 * @Version 1.0
 **/
public class Code25_isSymmetric {

    public boolean isSymmetric(TreeNode root) {
        return check(root.left, root.right);
    }

    public boolean check(TreeNode p, TreeNode q) {
        if (p == null && q == null) {
            return true;
        }
        if (p == null || q == null) {
            return false;
        }
        return p.val == q.val && check(p.left, q.right) && check(p.right, q.left);
    }


    @Test
    public void test(){
        TreeNode head = new TreeNode(1);
        TreeNode nodeL = new TreeNode(2);
        TreeNode nodeR = new TreeNode(2);
        TreeNode nodeLL = new TreeNode(3);
        TreeNode nodeLR = new TreeNode(4);
        TreeNode nodeRL = new TreeNode(4);
        TreeNode nodeRR = new TreeNode(3);
    }
}
